package com.infore.exchange.main.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.infore.common.base.EppPage;
import com.infore.common.base.Msg;
import com.infore.common.base.ResultUtil;
import com.infore.common.base.WrapperHelp;
import com.infore.common.fw.BaseController;
import com.infore.common.model.entity.exchange.TJobTaskInfo;
import com.infore.common.model.entity.vo.exchange.TJobTaskInfoVo;
import com.infore.exchange.main.service.TJobTaskInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 作业任务关联表 前端控制器
 * </p>
 *
 * @author lijh
 * @since 2023-02-13
 */
@RestController
@Api(value = "作业任务关联表前端控制器", tags = "作业任务关联表前端控制器")
@RequestMapping("/tJobTaskInfo")
public class TJobTaskInfoController extends BaseController {
	private String prefix = "/tJobTaskInfo";

	@Autowired
	private TJobTaskInfoService TJobTaskInfoService;

	@GetMapping()
	public String TJobTaskInfoController(){
		return prefix;
	}

	/**
	 * 查询作业任务关联表列表
	 * @param tjobtaskinfoVo 作业任务关联表的vo类
	 * @return Msg<Object> 结果集
	 * @author lijh
	 * @since 2023-02-13
	 */
	@PostMapping("/list")
	@ResponseBody
	@ApiOperation(value = "查询作业任务关联表列表", notes = "作业任务关联表列表查询 ")
	public Msg<Object> list(TJobTaskInfoVo tjobtaskinfoVo){
		//sql查询条件
		Wrapper<TJobTaskInfo> wrapper = null ;
		try {
			wrapper = (Wrapper<TJobTaskInfo>) WrapperHelp.addCondition(new EntityWrapper<TJobTaskInfo>(), tjobtaskinfoVo);
		} catch (Exception e) {
			e.printStackTrace();
			return ResultUtil.error(500,e.getMessage());
		}
		//查询方法
		Page<TJobTaskInfo> eppPage = new EppPage<TJobTaskInfo>(TJobTaskInfoService,tjobtaskinfoVo,wrapper);
		return ResultUtil.successPage(TJobTaskInfoService.selectPage(eppPage, wrapper));
	}

	/**
	 * 删除作业任务关联表
	 *
	 * @param  id
	 * @return Msg<Object>
	 * @author lijh
	 * @since 2023-02-13
	 */
	@RequestMapping(value = "/del", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
	@ApiOperation(value = "删除作业任务关联表", notes = "删除作业任务关联表")
	public Msg<Object> del(String id) {

		Map<String, Object> columnMap = new HashMap<String, Object>();
		columnMap.put("id", id);
		boolean flag = TJobTaskInfoService.deleteByMap(columnMap);
		return ResultUtil.setResult(flag);
	}
}
